import java.io.File;

/**
 * 描述:
 * 重命名文件/文件夹
 * @author Zhanggq
 * @date 2019/9/9 16:32
 */
public class RenameFile {

    public static void main(String[] args) {
        File oldFile = new File("D:\\考勤\\重新命名文件.txt");
        File newFile = new File("D:\\考勤\\重新命名文件2.txt");
        File oldDir = new File("D:\\考勤");
        File newDir = new File("D:\\考勤2");
        System.out.println("rename file:" + oldFile.renameTo(newFile));
        System.out.println("rename directory:" + oldDir.renameTo(newDir));
    }

}
